package com.study.cloud.config;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Mono;

@Configuration
public class MyConfig {


    @Bean
    public KeyResolver ipAddressResolver() {

        return exchange -> {
            String hostAddress = exchange.getRequest().getRemoteAddress().getAddress().getHostAddress();
            System.out.println("地址:"+hostAddress);
            return Mono.just(hostAddress);
        };
    }

}
